<template>
    <div>
        <el-row>
        <b>处理状态：</b>
        <el-radio-group v-model="radio1" @change="initTable">
        <el-radio-button label="0" value>全部</el-radio-button>
        <el-radio-button label="1">已处理</el-radio-button>
        <el-radio-button label="2">未处理</el-radio-button>
        </el-radio-group>
        </el-row>
        <el-row>
        <b>挪车电话：</b>
        <el-radio-group v-model="radio2" @change="initTable">
        <el-radio-button label="0" value>全部</el-radio-button>
        <el-radio-button label="1">存在电话</el-radio-button>
        <el-radio-button label="2">未存电话</el-radio-button>
        </el-radio-group>
        </el-row>
        <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="licensePlateNumber"
        label="车牌号码">
      </el-table-column>
      <el-table-column
        prop="reason"
        label="挪车原因">
      </el-table-column>
      <el-table-column
        prop="isHaveNumber"
        label="库中是否有挪车电话">
        <template slot-scope="scope">
            <el-tag :type="scope.row.isHaveNumber == 1?'success':'info'">{{ scope.row.isHaveNumber == 1?"有":"没有" }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="processingStatus"
        label="处理状态">
        <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.processingStatus == 1">未处理</el-tag>
            <el-tag type="info"  v-if="scope.row.processingStatus == 2">已完成</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="申请时间">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-search" @click="ToMqInfo(scope.row.id)" >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
    </div>
</template>

<script>
export default {
    name:'moveRequest',
    data(){
        return{
            radio1: "0",
            tableData: [],
            currentPage:1,
            pageSize:10,
            total:0,
            radio2: "0"
        }
    },
    created(){
      this.initAuthority()
    },
    methods:{
      initAuthority(){
        this.$request.get("/role/authority",{
          params:{
            id: JSON.parse(localStorage.getItem("admin")).id,
            index: 7
          }
        })
        .then(res =>{
          this.Authority = res.data
          if(res.data == '1'){
            this.initTable()
          }else{
            this.$message.error("你没有权限访问此功能")
            // this.$router.push("/")
          }
        })
        .catch(err =>{
          console.log(err)
        })

      },
        ToMqInfo(id){
          this.$router.push({
            path: 'moveRequestInfo',
            query:{
              ID:id
            }
           })
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.pageSize = val
            this.initTable()
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.currentPage = val
            this.initTable()
        },
        initTable(){
          this.$request.get("/move-request/page",{
              params:{
                  page: this.currentPage,
                  size: this.pageSize,
                  status:this.radio1,
                  processingStatus:this.radio1,
                  isHaveNumber:this.radio2
              }
          }).then(res => {
              this.tableData = res.data.records
              this.total = res.data.total
          }).catch(err =>{
              console.log(err)
          })
        },
    }
}
</script>

<style>
    .el-row{
        margin-bottom: 20px;
    }
</style>